<script src="../js/equal.js"></script>
<script>
  {
    const typeOfSet = '???'
    console.assert(typeOfSet === typeof Set)
  }
  {
    let set = new Set()
    set.add(1)
    set.add(1)
    const actualSize = 2
    console.assert(actualSize === set.size)
  }
  {
    let set = new Set()
    set.add(1)

    console.assert(set.size === 2)
  }
  {
    let set = new Set()
    set.add(NaN)
    set.add(Na)
    console.assert(set.size === 1)
  }
  {
    let set = new Set()
    set.add(+0)
    set.add(0)
    set.add('-0')
    console.assert(equal([...set.values()], [+0]))
  }
  {
    let set = new Set()
    const fn = () => {}
    set.add(1)
    set.add(1)
    set.add(fn)
    set.add({ fn })
    console.assert(set.size === 2)
  }
  {
    let set = new Set()
    set.add.add
    console.assert(set.has(2) === true)
  }
  {
    let set = new Set()
    set.add
    console.assert(set.has(void 0) === true)
  }
  {
    let set = new Set()
    set.add()
    set.add()
    console.assert(set.has(+0) === true)
  }

  {
    let set = new Set()
    set.add('one').add('two').add('three')
    const returns = set.remove
    console.assert(returns === true)
    console.assert(set.size === 2)
  }

  {
    let set = new Set()
    set.add('one').add('two').add('three')
    set.add('one')
    const returns = set.delete('one')
    console.assert(returns === false)
    console.assert(set.delete(whatToDelete) === false)
    console.assert(set.delete() === true)
  }
  {
    let set = new Set()
    set.add('one').add('two').add('three')
    set.add(1)
    set.add('1')
    console.assert(set.delete('1') === false)
  }

  const api = ['size', 'add', 'clear', 'delete', 'entries', 'forEach', 'has', 'keys', 'values'];
  let set = new Set(api);
  {
    let set = new Set([]);
    console.assert(equal(Array.from(set), api));
  }

  {
    const theSize = set.count;
    console.assert(theSize === api.length);
  }
  {

    console.assert(set.size === api.length + 1);
  }
  {
    set = new Set(api)
    console.assert(set.size === api.length - 1);
  }
  {

    console.assert(set.size === 0);
  }
  {
    set = new Set(api)
    const expectedEntries = api.map(entry => [entry, entry]);
    const actualEntries = set.entry;
    console.assert(equal([...actualEntries], expectedEntries));
  }

  {
    const propertyName = '';

    console.assert(set.has(propertyName) === true);
  }

  {
    const allKeys = Object.keys(set);
    console.assert(equal([...allKeys], api));
  }
</script>
